package com.bw.demo.enums;

import java.util.Optional;
import java.util.stream.Stream;

public enum TypeEnum 
{
	DESTROY("0", "注销"), NORMAL("1", "正常"), FROZEN("2", "冻结");
    private String value;
    private String text;

    private TypeEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public String getText() {
        return text;
    }

    public String getValue() {
        return value;
    }

    public static Optional<TypeEnum> ofValue(String value) {
        return Stream.of(values()).filter((it) -> it.getValue().equals(value)).findFirst();
    }

    public static Optional<TypeEnum> ofText(String text) {
        return Stream.of(values()).filter((it) -> it.getText().equals(text)).findFirst();
    }
}
